# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Štěpán Němec <stepnem@gmail.com>

pkgname=pypinyin
pkgver=0.48.0
pkgrel=2
pkgdesc='Chinese characters transliteration module and tool'
arch=('any')
url='https://github.com/mozillazg/python-pinyin'
license=('MIT')
depends=('python')
makedepends=('python-setuptools' 'phrase-pinyin-data' 'pinyin-data')
checkdepends=('python-pytest-cov')
source=("https://github.com/mozillazg/python-pinyin/archive/v$pkgver/python-pinyin-$pkgver.tar.gz")
sha256sums=('3fd48ae19e9cd3755cdc6a6da579df1108725324070f2af6b130bdb98fa53c05')

prepare() {
  cd python-pinyin-$pkgver
  ln -s /usr/share/pinyin-data/pinyin.txt pinyin-data/
  ln -s /usr/share/phrase-pinyin-data/pinyin.txt phrase-pinyin-data/
}

build() {
  cd python-pinyin-$pkgver
  make gen_data
  python setup.py build
}

check() {
  cd python-pinyin-$pkgver
  pytest pypinyin tests
}

package() {
  cd python-pinyin-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
  install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname/
}
